function [der]=dery(coor,data,n_nodes)
%% Finite Different Scheme
% This program is used to calculate the first & second (both second
% order) derive of the discret coor

for i=1:n_nodes        
    if (i<round(n_nodes/2))
        hp1=coor(i+1)-coor(i);
        hp2=coor(i+2)-coor(i);
        if (i==1)
            n1=-hp2/hp1/(hp1-hp2);
            p1=hp1/hp2/(hp1-hp2);
            s1=-(n1+p1);
            der(i,1)=s1*data(i)+n1*data(i+1)+p1*data(i+2);           
        else
            hm1=coor(i-1)-coor(i);
            m1=-hp1/(-hp1*hm1+hm1*hm1);
            n1=-hm1/(-hp1*hm1+hp1*hp1);
            s1=-(m1+n1);
            der(i,1)=m1*data(i-1)+s1*data(i)+n1*data(i+1); 
        end
    else
        hm1=coor(i-1)-coor(i);
        hm2=coor(i-2)-coor(i);        
        if (i==n_nodes)
            m1=-hm2/hm1/(hm1-hm2);
            p1=hm1/hm2/(hm1-hm2);
            s1=-(m1+p1);
            der(i,1)=s1*data(i)+m1*data(i-1)+p1*data(i-2);         
        else
            hp1=coor(i+1)-coor(i);
            m1=-hp1/(-hp1*hm1+hm1*hm1);
            n1=-hm1/(-hp1*hm1+hp1*hp1);
            s1=-(m1+n1);
            der(i,1)=m1*data(i-1)+s1*data(i)+n1*data(i+1); 
        end        
    end
        
end
